package com.kly.sc.api.application.controller.user.request;

import com.fqgj.common.api.ParamsObject;
import com.kly.sc.api.infras.enums.RestCodeEnum;
import com.kly.sc.api.infras.exception.ApplicationException;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 推荐用户列表请求类
 * @author linqu
 */
public class RecommendUsersRequest extends ParamsObject {
    /**
     * 推荐记录数
     */
    private Integer recordNum;

    public Integer getRecordNum() {
        return recordNum;
    }

    public void setRecordNum(Integer recordNum) {
        this.recordNum = recordNum;
    }


    @Override
    public void validate() {

        // recordNum未填默认显示10条
        if (Objects.isNull(this.recordNum) || this.recordNum < 0) {
            this.recordNum = 10;
        }
        // recordNum超过50提示错误
        else if (this.recordNum > 50) {
            throw new ApplicationException(RestCodeEnum.DATA_TOO_LONG);
        }

    }
}
